package com.nicy.angel.ulits.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter
@Slf4j
public class TimeCostFilter implements Filter {

    public TimeCostFilter(){
        System.out.println("construct");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          log.info("start on times");
          long start = System.currentTimeMillis();
          chain.doFilter(request,response);
          long end = System.currentTimeMillis();
          long time = end - start;
        System.out.println("time(ms):"+ time);
    }
}
